<template>
    <div>
      <div class="row">
        <div style="flex-shrink: 0;font-size: 14px;">序号：</div><el-input size="mini" style="width: 60px;margin-right: 20px;" v-model="nodeModel.sort"></el-input>
        <div style="flex-shrink: 0;font-size: 14px;">是否显示：</div><el-switch v-model="nodeModel.isShow" :active-value="true" :inactive-value="false" active-color="#13ce66" inactive-color="#999999"></el-switch>
      </div>
      <div class="row">
          <div style="flex-shrink: 0;font-size: 14px;margin-right: 10px;">标题：</div><el-input size="mini" style="width: 120px;margin-right: 20px;"  v-model="nodeModel.title"></el-input>
          <div style="flex-shrink: 0;font-size: 14px;">背景色：</div>
          <el-input size="mini" style="width: 100px;"  v-model="nodeModel.background"></el-input>
          <el-color-picker v-model="nodeModel.background"></el-color-picker>
      </div>
      <div class="column">
          <jcSlider title="上外边距："><el-slider slot="slider" v-model="nodeModel.marginTop" :min="0" :max="750" show-input input-size="mini"></el-slider></jcSlider>
          <jcSlider title="下外边距："><el-slider slot="slider" v-model="nodeModel.marginBottom" :min="0" :max="750" show-input input-size="mini"></el-slider></jcSlider>
          <jcSlider title="左右外边距："><el-slider slot="slider" v-model="nodeModel.marginLeft" :min="0" :max="750" show-input input-size="mini"></el-slider></jcSlider>
      </div>
      <div class="column">
          <jcSlider title="上内边距："><el-slider slot="slider" v-model="nodeModel.paddingTop" :min="0" :max="750" show-input input-size="mini"></el-slider></jcSlider>
          <jcSlider title="下内边距："><el-slider slot="slider" v-model="nodeModel.paddingBottom" :min="0" :max="750" show-input input-size="mini"></el-slider></jcSlider>
          <jcSlider title="左内边距："><el-slider slot="slider" v-model="nodeModel.paddingLeft" :min="0" :max="750" show-input input-size="mini"></el-slider></jcSlider>
      </div>
      <itemInfo :nodeModel="nodeModel"></itemInfo>
      <!-- 图文列表内容区域 -->
      <div style="border: 1px solid #eee;padding: 10px;margin-top: 10px;"
        v-if="name=='itemGrid'">
        <div style="display: flex;flex-direction: row;margin-bottom: 10px;position: relative;margin-top: 20px;" v-for="(item, index) in nodeModel.advertList" :key='index'>
          <el-image
          style="width: 100px; height: 100px;flex-shrink: 0;"
          :src="item.itemModel.coverUrl"
          fit="cover"></el-image>
          <div style="width: 100%;">
            <div style="display: flex;flex-direction: row;align-items: center;margin-left: 10px;"><div style="flex-shrink: 0;">序号：</div><el-input style="width: 60px;" v-model="item.sort"></el-input></div>
            <div style="margin-left: 10px;margin-top: 10px;display: flex;flex-direction: row;">
              <div style="width: 100%;"><el-input style="margin-left: 0px;" v-model="item.itemModel.id" disabled></el-input></div>
            </div>
            <div style="margin-left: 10px;margin-top: 10px;display: flex;flex-direction: row;">
              <div style="width: 100%;"><el-input style="margin-left: 0px;" v-model="item.itemModel.itemName" disabled></el-input></div>
              <div><el-button @click="selectRoute(item)">选择商品</el-button></div>
            </div>
          </div>
          <div style="position: absolute;left: -15px;top: -15px;" @click="deleteAdvert(index)"><i class="el-icon-circle-close"></i></div>
        </div>
        <div style="width: 100%;"><el-button @click="insertAdvert">添加一个</el-button></div>
      </div>
      <div style="border: 1px solid #eee;padding: 10px;"
        v-if="name=='itemList'">
        <div style="margin-left: 10px;margin-top: 10px;display: flex;flex-direction: row;">
          <div style="width: 100%;"><el-input style="margin-left: 0px;" v-model="nodeModel.link"></el-input></div>
          <div><el-button @click="selectRoute">选择过滤条件</el-button></div>
        </div>
      </div>
    </div>
</template>

<script>
    import custom from '@/components/jcupload/custom'
    import jcSlider from '@/views/page/composing/components/jc-slider'
    import itemInfo from '@/views/page/composing/placeRight/components/itemInfo'
  export default {
    components: {
        custom,
        jcSlider,
        itemInfo
    },
    props:{
        nodeModel:{
            type: Object,
            default: res=>{}
        },
        name:{
          type: String,
          default: ''
        }
    },
    data() {
      return {

      }
    },
    methods:{
        insertAdvert(){
            this.$emit('insertAdvert', {name: this.name})
        },
        deleteAdvert(index){
            this.$emit('deleteAdvert', index)
        },
        selectRoute(e){
            this.$emit('selectRoute', e)
        }
    }
  }
</script>

<style lang="scss" scoped>
     @import './commonStyle.scss';
</style>